// 定义PWM引脚
const int pwmPin = 3;

void setup() {
  // 将PWM引脚设置为输出模式
  pinMode(pwmPin, OUTPUT);
}

void loop() {
  // 逐渐增加LED亮度
  for (int brightness = 0; brightness <= 255; brightness++) {
    analogWrite(pwmPin, brightness);
    delay(10);
  }

  // 逐渐降低LED亮度
  for (int brightness = 255; brightness >= 0; brightness--) {
    analogWrite(pwmPin, brightness);
    delay(10);
  }
}